import { createTheme, Theme, CreateThemeOptions } from "@rneui/themed";
import { lightTheme, darkTheme } from "@/styles/theme.style";

/**
 * 创建 RNEUI 浅色主题
 * 基于现有的浅色主题配置
 */
export const createLightRNEUITheme = (): CreateThemeOptions => {
  return {
    lightColors: {
      primary: lightTheme.primary,
      secondary: lightTheme.primary,
      background: lightTheme.background,
      white: lightTheme.text.white,
      black: lightTheme.text.primary,
      grey0: lightTheme.text.primary,
      grey1: lightTheme.text.secondary,
      grey2: lightTheme.border.medium,
      grey3: lightTheme.border.light,
      grey4: lightTheme.backgroundLight,
      grey5: lightTheme.backgroundHighlight,
      greyOutline: lightTheme.border.light,
      searchBg: lightTheme.inputBackground,
      success: lightTheme.status.success,
      error: lightTheme.status.error,
      warning: lightTheme.status.warning,
      divider: lightTheme.border.divider,
    },
    components: {
      Button: {
        raised: true,
      },
      Card: {
        containerStyle: {
          borderRadius: 8,
          backgroundColor: lightTheme.card.background,
        },
      },
      Text: {
        style: {
          color: lightTheme.text.primary,
        },
      },
      Input: {
        containerStyle: {
          backgroundColor: lightTheme.inputBackground,
          borderRadius: 8,
        },
        inputStyle: {
          color: lightTheme.text.primary,
        },
        placeholderTextColor: lightTheme.text.hint,
      },
    },
  };
};

/**
 * 创建 RNEUI 深色主题
 * 基于现有的深色主题配置
 */
export const createDarkRNEUITheme = (): CreateThemeOptions => {
  return {
    darkColors: {
      primary: darkTheme.primary,
      secondary: darkTheme.primary,
      background: darkTheme.background,
      white: darkTheme.text.white,
      black: darkTheme.text.primary,
      grey0: darkTheme.text.primary,
      grey1: darkTheme.text.secondary,
      grey2: darkTheme.border.medium,
      grey3: darkTheme.border.light,
      grey4: darkTheme.backgroundLight,
      grey5: darkTheme.backgroundHighlight,
      greyOutline: darkTheme.border.light,
      searchBg: darkTheme.inputBackground,
      success: darkTheme.status.success,
      error: darkTheme.status.error,
      warning: darkTheme.status.warning,
      divider: darkTheme.border.divider,
    },
    components: {
      Button: {
        raised: true,
      },
      Card: {
        containerStyle: {
          borderRadius: 8,
          backgroundColor: darkTheme.card.background,
        },
      },
      Text: {
        style: {
          color: darkTheme.text.primary,
        },
      },
      Input: {
        containerStyle: {
          backgroundColor: darkTheme.inputBackground,
          borderRadius: 8,
        },
        inputStyle: {
          color: darkTheme.text.primary,
        },
        placeholderTextColor: darkTheme.text.hint,
      },
    },
  };
};

/**
 * 根据当前主题模式获取对应的 RNEUI 主题
 */
export const getRNEUITheme = (isDark: boolean): CreateThemeOptions => {
  return isDark ? createDarkRNEUITheme() : createLightRNEUITheme();
};
